1
|
|
|
const chai = require("chai"), |
2
|
|
|
MethodsParser = require("../../src/2.0/MethodsParser"), |
3
|
|
|
SecuritySchemesParser = require("../../src/2.0/SecuritySchemesParser"), |
4
|
|
|
testData = { |
5
|
|
|
empty: { |
6
|
|
|
'\/user\/auth\/facebook': { |
7
|
|
|
'post': { |
8
|
|
|
'tags' : [ |
9
|
|
|
'User auth' |
10
|
|
|
], |
11
|
|
|
'summary' : 'Register & login user from facebook', |
12
|
|
|
'description': 'Register & login user from facebook', |
13
|
|
|
'produces' : [ |
14
|
|
|
'application\/json' |
15
|
|
|
], |
16
|
|
|
} |
17
|
|
|
} |
18
|
|
|
}, |
19
|
|
|
parameters: { |
20
|
|
|
'\/user\/auth\/facebook': { |
21
|
|
|
'post': { |
22
|
|
|
"tags" : [ |
23
|
|
|
"User auth" |
24
|
|
|
], |
25
|
|
|
"summary" : "Register & login user from facebook", |
26
|
|
|
"description": "Register & login user from facebook", |
27
|
|
|
"produces" : [ |
28
|
|
|
"application\/json" |
29
|
|
|
], |
30
|
|
|
"parameters" : [ |
31
|
|
|
{ |
32
|
|
|
"name" : "test", |
33
|
|
|
"in" : "query", |
34
|
|
|
"description": "Test Parameter", |
35
|
|
|
"type" : "string", |
36
|
|
|
"default" : "test" |
37
|
|
|
} |
38
|
|
|
], |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
chai.should() |
45
|
|
|
|
46
|
|
|
describe('Test methods parser', () => { |
47
|
|
|
it('should test empty method', function () { |
48
|
|
|
const security = new SecuritySchemesParser({}), |
49
|
|
|
methodsParser = new MethodsParser(testData.empty, security) |
50
|
|
|
|
51
|
|
|
let data = methodsParser.parse() |
52
|
|
|
|
53
|
|
|
data.should.be.a('array') |
54
|
|
|
data.should.length(1) |
55
|
|
|
data[0].path.should.be.equal('/user/auth/facebook') |
56
|
|
|
data[0].method.should.be.equal('POST') |
57
|
|
|
data[0].isPOST.should.be.true |
58
|
|
|
data[0].isGET.should.be.false |
59
|
|
|
data[0].isDeprecated.should.be.false |
60
|
|
|
data[0].summary.should.be.equal('Register & login user from facebook') |
61
|
|
|
}) |
62
|
|
|
|
63
|
|
|
it('should test with empty responses', function () { |
64
|
|
|
const security = new SecuritySchemesParser({}), |
65
|
|
|
methodsParser = new MethodsParser(testData.parameters, security) |
66
|
|
|
|
67
|
|
|
let data = methodsParser.parse() |
68
|
|
|
|
69
|
|
|
data.should.be.a('array') |
70
|
|
|
data.should.length(1) |
71
|
|
|
data[0].path.should.be.equal('/user/auth/facebook') |
72
|
|
|
data[0].method.should.be.equal('POST') |
73
|
|
|
data[0].isPOST.should.be.true |
74
|
|
|
data[0].isGET.should.be.false |
75
|
|
|
data[0].isDeprecated.should.be.false |
76
|
|
|
data[0].summary.should.be.equal('Register & login user from facebook') |
77
|
|
|
data[0].parameters.should.be.a('array') |
78
|
|
|
data[0].parameters.should.length(1) |
79
|
|
|
data[0].parameters.should.length(1) |
80
|
|
|
}) |
81
|
|
|
|
82
|
|
|
it('should test with response', function () { |
83
|
|
|
|
84
|
|
|
}) |
85
|
|
|
|
86
|
|
|
it('should test with response & security schema', function () { |
87
|
|
|
|
88
|
|
|
}) |
89
|
|
|
}) |